package org.ph.share.lock.test.thread;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * Thread 测试类
 * 泡茶demo
 *
 * @author Hush.
 * @since 2023/5/15 9:53
 */
@Slf4j
public class ThreadTest5 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread("t1") {
            @SneakyThrows
            @Override
            public void run() {

                log.info("tea - 1 洗水壶");
                TimeUnit.SECONDS.sleep(1);

                for (int i = 3; i <= 10; i++) {
                    TimeUnit.SECONDS.sleep(1);
                    log.info("tea - 2 开始烧水壶,度数:{}", i * 10);
                }

            }
        };
        Thread thread2 = new Thread("t2") {
            @SneakyThrows
            @Override
            public void run() {
                log.info("tea 洗茶壶");
                TimeUnit.SECONDS.sleep(1);
                log.info("tea 洗茶杯");
                TimeUnit.SECONDS.sleep(2);
                log.info("tea 拿茶叶");
                TimeUnit.SECONDS.sleep(1);
                // 这边t2线程等待t1线程结束开始泡茶
                thread.join();
                log.info("泡茶时间....");
            }
        };
        thread.start();
        thread2.start();
    }
}
